Sendmail functionality using DXL

Hello,

I am new to DXL. Please guide me how to do send mail functionality with image file attachment in DXL coding.

Thanks in advance,
Muthurani M
muthurani - Thu Feb 18 02:32:35 EST 2010

Re: Sendmail functionality using DXL
llandale - Thu Feb 18 18:12:16 EST 2010

The basic command is this:
bool sendEMailMessage(string sFrom, string sTo, string sSubject, string sMessage)

Try this:

string From = 
"MyName@MyCompany.com" string To   = 
"MyBoss@MyCompany.com" string Subj = 
"Test Email from DXL" string Mess = 
"This is the body of the message"   sendEmailMessage(From, To, Subj, Mess)

I don't recall why I didn't like that. I wrote my own function:



const string    gl_OleOutlookApp        = 
"Outlook.Application"      
// Windows recognizes this as a running Outlook   bool fOleOK(string ErrMess, NameOfCommand) 
{       
// Deal with returned OLE string errors. 

if (!

null ErrMess) 
{  print 
"Ole Error: " NameOfCommand 
"\t" ErrMess 
"\n" 

return(

false) 
} 

else 

return 

true 
}     
//****************************** bool        fEmailCreateOutlookMail(bool DoSend, string SendTo, SendCC, SendBCC, Subject, Body) 
{       
// Create the Email message which requires that Outlook.exe is running. 
// SendTo, SendCC, and SendBCC should be valid Email addresses separated by semi-colons;. 
// Send the Message when DoSend, otherwise just display it.   bool          Result  = 

false OleAutoObj     oaoMessage      = 

null OleAutoObj      oaoOutlook      = oleGetAutoObject(gl_OleOutlookApp) 

if (

null oaoOutlook) 
{  fOleOK(
"Outlook not running", 
"GetOutlook")    
// Log Error 

return(

false) 
} OleAutoArgs   autoArgs        = create() clear(autoArgs) put(autoArgs, 0)        
// 0 is Outlook's symbolic constant for mail item   

if(fOleOK(oleMethod(oaoOutlook, 
"CreateItem", autoArgs, oaoMessage), 
"CreateMail")    and fOleOK(olePut(oaoMessage, 
"To",      SendTo),   
"To")         and fOleOK(olePut(oaoMessage, 
"CC",      SendCC),   
"CC")         and fOleOK(olePut(oaoMessage, 
"BCC",     SendBCC),  
"BCC")        and fOleOK(olePut(oaoMessage, 
"Subject", Subject),  
"Subject")    and fOleOK(olePut(oaoMessage, 
"Body",    Body),     
"Body") ) 
{               
// Message created OK. Send or just Show it 

if (DoSend) Result = fOleOK(oleMethod(oaoMessage, 
"Send"), 
"Send") 

else Result = fOleOK(oleMethod(oaoMessage, 
"Display"), 
"Display") 
} 

else Result = 

false delete(autoArgs) 

return(Result) 
}       
// end fEmailCreateOutlookMail()


IIRC, Outlook "is running" so long as it WAS running since Reboot. Open and close it and its still there to send Emails.

I don't see any reason why the Body could not be Rich text with OLE diagrams, but I doubt I tested doing anything like that.

  • Louie